﻿<UserControl x:Class="Hisaab.Client.Modules.Core.Account.View.AccountEditor"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:Converters="clr-namespace:Hisaab.Client.Modules.Core.Converters"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"  mc:Ignorable="d" d:DesignHeight="517" d:DesignWidth="652" >
    <UserControl.Resources>
        <Converters:AccountTypeImageConverter x:Key="accountImageConverter" UseLargeIcon="False"/>
    </UserControl.Resources>
    <Grid Margin="8" >
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="115" />
            <ColumnDefinition Width="4" />
            <ColumnDefinition Width="250" />
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="100" />
            <RowDefinition Height="36" />
            <RowDefinition Height="36" />
            <RowDefinition Height="36" />
            <RowDefinition Height="36" />
            <RowDefinition Height="36" />
            <RowDefinition Height="*" />
            <RowDefinition Height="36" />
        </Grid.RowDefinitions>
        <Label Grid.Column="0" Grid.Row="1" FontWeight="Bold" Style="{DynamicResource EditorLabel}">Title</Label>
        <TextBox Grid.Column="2" Grid.Row="1" Text="{Binding Path=SelectedAccount.Name, Mode=TwoWay, ValidatesOnDataErrors=True}" Style="{DynamicResource EditorTextBox}" />

        <Label Grid.Column="0" Grid.Row="2" Style="{DynamicResource EditorLabel}">Account Type</Label>
        <ComboBox Grid.Column="2" Grid.Row="2"
            ItemsSource="{Binding Path=AccountTypes}"
            SelectedValuePath="Id"
            SelectedValue="{Binding Path=SelectedAccount.AccountType}" Style="{DynamicResource EditorComboBox}">
            <ComboBox.ItemTemplate>
                <DataTemplate>
                    <StackPanel Orientation="Horizontal" >
                        <Image Source="{Binding Id, Converter={StaticResource accountImageConverter}}" Margin="3 3 10 3"/>
                        <TextBlock Text="{Binding Name}" VerticalAlignment="Center" />
                    </StackPanel>
                </DataTemplate>
            </ComboBox.ItemTemplate>
        </ComboBox>

        <Label Grid.Column="0" Grid.Row="3" FontWeight="Bold" Style="{DynamicResource EditorLabel}" Content="Account Number"></Label>
        <TextBox Grid.Column="2" Grid.Row="3" Text="{Binding Path=SelectedAccount.AccountNumber, Mode=TwoWay, ValidatesOnDataErrors=True}" Style="{DynamicResource EditorTextBox}" />

        <Label Content="Initial Balance " Grid.Row="4" Style="{DynamicResource EditorLabel}" Visibility="{Binding IsNewAccount, Converter={StaticResource VisibilityConverter}}" />
        <TextBox Grid.Column="2" Grid.Row="4" Text="{Binding Path=SelectedAccount.InitialBalance, Mode=TwoWay}" Visibility="{Binding IsNewAccount, Converter={StaticResource VisibilityConverter}}" Style="{DynamicResource EditorTextBox}" />

        <Label Content="Start Date" Grid.Row="5" Style="{DynamicResource EditorLabel}" Visibility="{Binding IsNewAccount, Converter={StaticResource VisibilityConverter}}" />
        <DatePicker Grid.Column="2" Grid.Row="5" Style="{DynamicResource EditorDatePicker}"
            Visibility="{Binding IsNewAccount, Converter={StaticResource VisibilityConverter}}"
            SelectedDate="{Binding Path=SelectedAccount.InitialBalanceDate, Mode=TwoWay}" />
        <StackPanel Grid.Column="0" Grid.ColumnSpan="4" VerticalAlignment="Center" Margin="20">
            <TextBlock Text="Add Account" Style="{DynamicResource MetroHeader}" />
        </StackPanel>
        <StackPanel Grid.Column="0"  Grid.ColumnSpan="4" Grid.Row="7" HorizontalAlignment="Right" Orientation="Horizontal">
            <Button IsDefault="True" Width="75" Command="{Binding SaveCommand}">
                <Button.Content>
                    <StackPanel Orientation="Horizontal">
                        <Image Source="pack://application:,,,/Hisaab.Client.Common;component/Resources/Images/16/save.png" Width="16" Height="16" Margin="0 0 5 0" />
                        <TextBlock>Save</TextBlock>
                    </StackPanel>
                </Button.Content>
            </Button>
            <Button IsCancel="True" Width="75" Command="Close" >Cancel</Button>
        </StackPanel>
    </Grid>
</UserControl>